﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Ext.Net;

public partial class UserControl_myColorComboBox : System.Web.UI.UserControl,INamingContainer
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //ExampleTabs.ActiveIndex = 1;
            RedSlider.Value = 255;
            GreenSlider.Value = 255;
            BlueSlider.Value = 255;
        }

    }

    //string _Color = "#FFFFFF";
    public string Color
    {
        get
        {
            return extDropField_Color.Text;
        }

        set
        {
            //_Color = value;
            extDropField_Color.Text = value;
            lb_SelectColor.Text = value;
            ColorPreview.StyleSpec = "background-color:" + value;
            setSliderValue(value);
        }
    }

    //string _Text = "#FFFFFF";
    public string Text
    {
        get
        {
            return extDropField_Color.Text;
        }

        set
        {
            //_Text = value;
            extDropField_Color.Text = value;
            lb_SelectColor.Text = value;
            setSliderValue(value);
        }
    }


    //string _FieldLabel = "颜色选择";
    public string FieldLabel
    {
        get
        {
            return extDropField_Color.FieldLabel;
        }

        set
        {
            extDropField_Color.FieldLabel = value;
        }
    }

    private void setSliderValue(string strColor)
    {
        if (strColor == null || strColor == "" || strColor.Length != 7)
            return;
        int intRed = Convert.ToInt32(strColor.Substring(1, 2), 16);
        int intGreen = Convert.ToInt32(strColor.Substring(3, 2), 16);
        int intBlue = Convert.ToInt32(strColor.Substring(5, 2), 16);

        RedSlider.Value = intRed;
        GreenSlider.Value = intGreen;
        BlueSlider.Value = intBlue;
    }
}
